//
//  XPresentationController.swift
//  SwiftStory
//
//  Created by ZxjMacBookPro on 2020/4/18.
//  Copyright © 2020 ZxjMacBookPro. All rights reserved.
//

import UIKit

class XPresentationController: UIPresentationController {

    var presentFrame = CGRect.zero
    
    //布局弹出界面
    override func containerViewWillLayoutSubviews() {
        presentedView?.frame = presentFrame
        
        containerView?.insertSubview(coverBtn, at: 0)
        coverBtn.addTarget(self, action: #selector(coverBtnClick), for: .touchUpInside)

    }

    @objc private func coverBtnClick(){
        NSLog(message: "消失")
        presentingViewController.dismiss(animated: true, completion: nil)
    }
    
    private lazy var coverBtn: UIButton = {
        let btn = UIButton()
        btn.frame = UIScreen.main.bounds
        
        return btn
    }()
}
